

#include <iostream>
#include <vector>
#include <list>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <functional>
using namespace std;

#if 0
int main()
{
    string s1, s2;
    cin >> s1 >> s2;

    int cnt[26] = { 0 };

    for (const auto& e : s1)
    {
        ++cnt[e - 'A'];
    }
    for (const auto& e : s2)
    {
        if (--cnt[e - 'A'] < 0)
        {
            cout << "No" << endl;
            return 0;
        }
    }

    cout << "Yes" << endl;
    return 0;
}
#endif

#if 0
int main()
{
    int n = 0;
    cin >> n;
    long long res = 0;
    vector<int> v(3 * n);

    for (int i = 0, tmp = 0; i < 3 * n; ++i)
    {
        cin >> tmp;
        v[i] = tmp;
    }

    sort(v.begin(), v.end(), greater<int>());

    for (int i = 1; i < 2 * n; i += 2)
    {
        res += v[i];
    }

    cout << res << endl;
}
#endif

#if 0
using PII = pair<int, int>;
struct comp
{
    bool operator()(const PII& x, const PII& y)
    {
        return (x.first * x.second > y.first* y.second) || (x.first * x.second == y.first * y.second && x.first > y.first);
    }
};

void op(vector<PII>& v, int goal)
{
    for (int i = 0, n = v.size(); i < n; ++i)
    {
        auto e = v[i];
        if (e.first == goal)
        {
            v.erase(v.begin() + i);
            break;
        }
    }
}

int main()
{
    int n = 0;
    cin >> n;
    int  res = 0;
    vector<PII> v;
    unordered_map<int, int> mp;

    for (int i = 0, tmp = 0; i < n; ++i)
    {
        cin >> tmp;
        ++mp[tmp];
    }

    for (auto it = mp.begin(); it != mp.end(); ++it)
    {
        v.push_back(*it);
    }
    sort(v.begin(), v.end(), comp());

    while (v.size())
    {
        auto it = v.begin();
        int bigger = (*it).first + 1;
        int smaller = (*it).first - 1;

        res += (*it).first;
        op(v, bigger);
        op(v, smaller);
        if (!--((*it).second))
            v.erase(it);
    }

    cout << res << endl;
}
#endif

// err
void Print(list<int>::iterator beg, list<int>::iterator end)
{
    for (int cnt = 1; beg != end; ++beg, ++cnt)
    {
        cout << (cnt == 1 ? "" : " ") << *beg;
    }
    cout << endl;
}

int main()
{
    int n = 0, m = 0;
    cin >> n >> m;
    unordered_map<int, int> mp;
    unordered_map<int, int> hash;

    for (int i = 0, a = 0, b = 0; i < m; ++i)
    {
        cin >> a >> b;
        mp[a] = b;
    }
    if (!mp.count(n))
        mp[n] = 0;

    vector<list<int>> vl;
    for (auto mit = mp.begin(); mit != mp.end(); ++mit)
    {
        list<int> ls;
        int flag = 0;
        int key = (*mit).first;
        while (mp.count(key))
        {
            if (!hash.count(key) || (hash.count(key) && (hash[key] != mp[key] || hash[key])))
            {
                if (!hash.count(key))
                    hash[key] = mp[key];
                ls.push_back(key);
                key = mp[key];
            }
            else
            {
                flag = 1;
                break;
            }
        }
        if (!flag && ls.size())
            vl.push_back(ls);
    }

    for (const auto& ls : vl)
    {
        unordered_set<int> tmphash;
        for (auto it = ls.begin(); it != ls.end(); ++it)
        {
            if (!tmphash.count(*it))
                tmphash.insert(*it);
            else
            {
                cout << -1 << endl;
                return 0;
            };
        }
    }

    list<int> ls = vl[0];
    for (int i = 1; i < vl.size(); ++i)
    {
        int flag = 0;
        auto it1 = ls.begin(), it2 = vl[i].begin();
        while (*it1 != *it2)
        {
            if (++it1 == ls.end())
            {
                if (++it2 == vl[i].end())
                {
                    flag = 1;
                    break;
                }
            }
        }

        if (!flag)
        {
            auto beg = it1;
            while (it1 != ls.end() && it2 != vl[i].end() && *it1 == *it2)
            {
                ++it1;
                ++it2;
            }

            ls = list<int>(beg, it1);
        }
    }

    if (ls.empty())
    {
        cout << "hello";
        Print(vl[0].begin(), vl[0].end());
    }

    for (auto& e : vl)
    {
        auto it = e.begin();
        for (; it != e.end() && *it != ls.front(); ++it);
        Print(e.begin(), it);
    }
    Print(ls.begin(), ls.end());
    for (auto& e : vl)
    {
        auto it = e.begin();
        for (; it != e.end() && *it != ls.back(); ++it);
        Print(++it, e.end());
    }

    return 0;
}